package com.ujoku.controller;

import com.labillusion.core.platform.web.rest.RESTController;
import com.ujoku.domain.Country;
import com.ujoku.service.CountryService;
import com.ujoku.view.builder.CountryViewBuilder;
import com.ujoku.view.domain.CountryListView;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * Created by Andy.Lian on 2015/1/25.
 */
@RestController
public class CountryController extends RESTController {
    @Autowired
    protected CountryService countryService;

    @Autowired
    private CountryViewBuilder countryViewBuilder;

    @RequestMapping(value="/country", method = RequestMethod.GET)
    @ResponseBody
    public CountryListView getCountryList()throws Exception {
        List<Country> countryList=countryService.selectList();
        CountryListView countryListView=countryViewBuilder.buildCountryView(countryList);
        return countryListView;
    }
}
